﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using MethodWorx.Core.DomainModel;
using MethodWorx.CMS.Configuration;
using MethodWorx.CMS.Providers;
using MethodWorx.CMS.Plugins;
using MethodWorx.CMS.Content;
using MethodWorx.Core.Serialization;
using System.IO;
using System.Xml;

namespace MethodWorx.CMS.Services
{
    public interface ISchemaService
    {
        PageTemplate CreatePageTemplate(string name, string description, bool allowedAtRoot, PageTemplate parent,
                                        bool isAbstract);

        IEnumerable<PageTemplate> GetAllPageTemplates();
        IEnumerable<PageTemplate> GetAbstractPageTemplates();
        PageTemplate GetAbstractPageTemplateByName(string name);
        IEnumerable<ContentTemplate> GetAllContentTemplates();
        PageTemplate GetPageTemplateById(Guid id);

        void ChildChildPageTemplateOf(PageTemplate parent, string name, string description, int? minimumRequired,
                                      int? maximumAllowed, string nameConstraint);

        void AddChildPageTemplateOf(PageTemplate parent, PageTemplate child, int? minimumRequired,
                                           int? maximumAllowed, string nameConstraint);

        PageTemplate GetRootPageTemplate();
        ContentTemplate GetContentTemplateById(Guid id);

        void AddChildContentTemplateOf(PageTemplate parent, ContentTemplate child, int? minimumRequired,
                                       int? maximumAllowed, string nameConstraint);

        void ChildChildContentTemplateOf(PageTemplate parent, string name, string description, int? minimumRequired,
                                         int? maximumAllowed, string nameConstraint);

        PageTemplate AddPageTemplateProperty(Guid id, string name, string type, ICustomPropertyDetails details);


        PageTemplate UpdatePageTemplateProperties(Guid id, IEnumerable<IPropertyDetails> propertyDetails);


        PageTemplate UpdatePageTemplateBasicDetails(Guid id, string name, string description, PageTemplate parent);


        PageTemplate SaveTemplate(PageTemplate pageTemplate, string template);

        void RemovePageTemplateProperty(PageTemplate pageTemplate, int index);


        string SerializeToXml();

        IEnumerable<PageTemplate> GetAllPageTemplatesContaining(ContentTemplate contentTemplate);


        IEnumerable<PageTemplate> GetAllPageTemplatesContaining(PageTemplate pageTemplate);


        void DeleteContentTemplate(ContentTemplate contentTemplate);


        void DeleteConstraint(PageTemplate pageTemplate, ContentTemplateConstraint constraint);


        void DeletePageTemplate(PageTemplate pageTemplate);

        void DeleteConstraint(PageTemplate pageTemplate, PageTemplateConstraint constraint);


        PageTemplate GetPageTemplateByName(string templateName);

        ContentTemplate GetContentTemplateByName(string templateName);
    }
}
